package service.impl;

import dao.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import pojo.Article;
import pojo.User;
import service.UserService;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService{
    @Autowired
    private UserMapper userMapper;

    public UserMapper getUserMapper() {
        return userMapper;
    }

    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public User login(String account) {
        return userMapper.login(account);
    }

    @Override
    public List<User> getAllUser(User user) {
        return userMapper.getAllUser(user);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int addUser(User user) {
        return userMapper.addUser(user);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public int clickToUser(int beclick,int id) {
        return userMapper.clickToUser(beclick,id);
    }

    @Override
    public List<User> getAllfirnd(int userId,int friendid) {
        return userMapper.getAllfirnd(userId,friendid);
    }

    @Override
    public int reportUser(int bereport,int id) {
        return userMapper.reportUser(bereport,id);
    }

    @Override
    public User updateUserMessage(String uid) {
        return userMapper.updateUserMessage(uid);
    }

    @Override
    public List<Article> getArticlesByUser(int id) {
        return userMapper.getArticlesByUser(id);
    }
}
